﻿using Microsoft.EntityFrameworkCore;

namespace CommonModel.DB
{
    /// <summary>
    /// mysql连接
    /// </summary>
    public class MySQLContext : DbContext
    {
        //数据库连接串
        private string connectionString = "";
        //MySQL数据版本
        private string version = "";
        public MySQLContext(DbContextOptions options) : base(options)
        {

        }

        public MySQLContext(DbContextOptions options, string connectionString, string version) : base(options)
        {
            this.connectionString = connectionString;
            this.version = version;
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseMySql(connectionString, ServerVersion.Parse(version));
            base.OnConfiguring(optionsBuilder);
        }
    }
}
